<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends ShareController {
	public function _initialize(){
		parent::_initialize();
		parent::header();
		parent::menu();
	}
	
	//个人中心页面
	public function index(){
		if( isset($_SESSION['uid']) && $_SESSION['uid'] !='' 
			&& isset($_SESSION['name']) && $_SESSION['name'] !='')
		{
			$this->display();
		}else{
			$this->redirect('/home/login/login');
		}
		
	}
	
	//个人信息页面
    public function information(){
		$id = I('get.id');
		
		$Userifo = M('Userifo');
		
		if( $id != ''){
			$list = $Userifo->where("user_id={$id}")->find();
		}
		
		$this->assign('list',$list);
        $this->display();
    }
    //新增地址页面
    public function address(){
		$id		= I('get.id');
		$act	= I('get.act'); 
		
		$address = M('Address');
		
		if( $id != ''){
			
			$list = $address->where("user_id={$id}")->select();
		}
		
		$this->assign('list',$list);
		$this->display();
	}
	
	//编辑地址页面
	public function edit(){
		$id		= I('get.id');
		$act	= I('get.act');
		
		$address = M('Address');
		
		if( $act == 't_del'){
			
			$ret = $address->where("id={$id}")->delete();
			
			if( $ret == false){
				$this->error('删除失败');
			}
			else{
				$this->success('删除成功');
			}
		}
		
		if( $id != ''){
			
			$list = $address->where("id={$id}")->find();
			
			$data = array(
				'id'	=>	$list['user_id']
			);
		}
		
		$this->assign('list',$list);
		$this->assign('data',$data);
		$this->display();
	}
	
	//订单管理页面
	public function order(){
		$id = I('get.id');
		
		$this->display();
	}
	
	//订单详情页面
	public function orderinfo(){
		$this->display();
	}
	
	//查看物流页面
	public function logistics(){
		$this->display();
	}
	
	//评价管理页面
	public function comment(){
		
		
		$this->display();
	}
	
	//买家评价页面
	public function commentlist(){
		$order_id = I('get.order_id');
		
		$Shopcar = M('Ware_shopcar');
		
		$list = $Shopcar->where("order_id={$order_id} and status=0")->select();
		
		$this->assign('list',$list);
		$this->display();
	}
	
}
